package xyz.haijin.mybatisplus.model;

//import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

//@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private String return_code;
    private String return_msg;

    private T result;

    public Result(){

    }

    private Result(String return_code, String return_msg) {
        this.return_code = return_code;
        this.return_msg = return_msg;
    }

    private Result(String return_code, T result, String return_msg) {
        this.return_code = return_code;
        this.return_msg = return_msg;
        this.result = result;
    }

    public static <T> Result<T> error(String return_code,String message){
        Result result = new Result(return_code,message);
        return result;
    }

    public static <T> Result<T> error(String return_code,T data,String message){
        Result result = new Result(return_code,data,message);
        return result;
    }

    public static <T> Result<T> success(T data,String message){
        return new Result("0",data,message);
    }

    public static <T> Result<T> success(String message){
        return (Result<T>)success(null,message);
    }

    public static <T> Result<T> success(){
        return (Result<T>)success(null,"处理成功");
    }

    public static <T> Result<T> success(T data){
        return (Result<T>)success(data,"处理成功");
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getReturn_code() {
        return return_code;
    }

    public void setReturn_code(String return_code) {
        this.return_code = return_code;
    }

    public String getReturn_msg() {
        return return_msg;
    }

    public void setReturn_msg(String return_msg) {
        this.return_msg = return_msg;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    @Override
    public String toString() {
        return "Result{" +
                "return_code=" + return_code +
                ", return_msg='" + return_msg + '\'' +
                ", result=" + result +
                '}';
    }
}

